uniform float mouseX;
uniform float mouseY;
uniform float radius;
uniform sampler2D texture;

void main()
{
    vec4 c = texture2D(texture, gl_TexCoord[0].xy);
    vec2 mousePosition = vec2(mouseX, mouseY);
    vec2 planeCoords = vec2(gl_TexCoord[0].st);
    float dist = distance(mousePosition, planeCoords);
    vec4 color;
    color.rgb = gl_Color.rgb * gl_Color.a;
    color.a = gl_Color.a;

    if(dist > radius && radius > 0)
    {
        float r = c.r * color.r;
        float g = c.g * color.g;
        float b = c.b * color.b;
        float minRGB = min(min(r, g), b);
    	
    	gl_FragColor.r = minRGB;//*ratio + (1.0-ratio)*r;
    	gl_FragColor.g = minRGB;//*ratio + (1.0-ratio)*g;
    	gl_FragColor.b = minRGB;//*ratio + (1.0-ratio)*b;
    	gl_FragColor.a = c.a*color.a;
    }
    else
    {
//    	float ratio = dist/radius;
	   	gl_FragColor = c*color;
    }
}